
local partInfo={}
local partCount=0
local probabilitySum=0

local probability={}
local multiplier = 10^20 --大乘数
-- 1:钻头，2：车轮，3：车身，4：推进器：5 装饰
local typeWeight={
    [1]=5,
    [4]=5,
    [2]=10,
    [3]=10,
    [5]=20,
}

for _,v in pairs(script:GetChildren()) do
    for j,k in pairs(require(v)) do
        k.weight=k.weight*typeWeight[k.type]
        local pb=math.floor(multiplier/k.weight) --真正的概率
        -- probability[j]=pb
        table.insert(probability,{
            id=j,
            p=pb
        })
        partInfo[j]=k
        partCount=partCount+1
        probabilitySum=probabilitySum+pb
    end
end

table.sort(probability,function(a,b)
        return a.p<b.p
end)

return {
    Info=partInfo, --部件配置信息
    PartCount=partCount,--部件总数量
    ProbabilitySum=probabilitySum,--部件概率和
    Probability=probability--部件概率表{id=权重}
}
